package com.cskaoyan.controller;

import com.cskaoyan.bean.Number1;
import com.cskaoyan.vo.BaseRespVo;
import com.cskaoyan.vo.LoginData;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Map;

@RestController
public class AuthController {

    @RequestMapping("admin/auth/login")
    public BaseRespVo login(@RequestBody Map map){//也可以使用JavaBean来接收
        String username = (String) map.get("username");
        String password = (String) map.get("password");
        //登录的业务
        return BaseRespVo.ok("dgksljgkldsajfgk");
    }

    @RequestMapping("admin/auth/info")
    public BaseRespVo info(String token) {

        //业务自己来添加 👉 这里应该来源于数据库
        LoginData loginData = new LoginData();
        loginData.setAvatar("https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
        loginData.setName("超级管理员");
        ArrayList<String> perms = new ArrayList<>();
        perms.add("*");
        loginData.setPerms(perms);

        ArrayList<String> roles = new ArrayList<>();
        roles.add("超级管理员");
        loginData.setRoles(roles);

        return BaseRespVo.ok(loginData);
    }
    @RequestMapping("admin/dashboard")
    public BaseRespVo sdads(){
        Number1 number = new Number1();
        number.setGoodsTotal(211);
        number.setOrderTotal(166);
        number.setProductTotal(266);
        number.setUserTotal(6);

        return  new BaseRespVo().ok(number);
    }
}
